/* eslint-disable */
const Service = require('egg').Service;
const { Op } = require('sequelize');

class FavoriteService extends Service {
    async findList(pageIndex = 1, pageSize = 5,keyword='') {
        const { ctx } = this;
        const offset = (pageIndex - 1) * pageSize
        const where = {};
        if (keyword) {
            where.keyword = { [Op.like]: `%${keyword}%` };
        }
        return await ctx.model.Favorite.findAndCountAll({
            include:[
                {
                    model:ctx.model.User,
                    as:'user'
                },
                {
                    model:ctx.model.Outfit,
                    as:'outfit' ,
                    attributes: ['title', 'desc'],
                },
            ],
            offset: Number(offset),
            limit: Number(pageSize)
        })
    }
}
module.exports = FavoriteService;